// Typescript类型、接口、类、泛型

interface DBI<T> {
  add(info: T):boolean;
  update(info: T, id: number): boolean;
  delete(id: number): boolean;
  get(id: number): any[];
}

// 定义一个操作mysql数据库的类
// 注意：要实现泛型接口，这个类也应该时一个泛型类
class MysqlDb<T> implements DBI<T>{
  add(info: T): boolean {
    console.log(info)
    return true
  }
  update(info: T, id: number): boolean {
    return true
  }
  delete(id: number): boolean {
    return true
  }
  get(id: number): any[] {
    return []
  }
}


class MsSqlDb<T> implements DBI<T> {
  add(info: T): boolean {
    return true
  }
  update(info: T, id: number): boolean {
    return true
  }
  delete(id: number): boolean {
    return true
  }
  get(id: number): any[] {
    return []
  }
}

// 操作用户表，定义一个
class User{
  username: string | undefined;
  password: string | undefined;
}
var u = new User()
u.username = '张三'
u.password = '1234456'

var oMysql = new MysqlDb<User>()
var oMysql = new MysqlDb<User>()
oMysql.add(u)


export {}